home *** CD-ROM | disk | FTP | other *** search
- '
- ' Example script to display a message dialog box if the free
- ' disk space on one or more drives is below a certain leve;
- '
- ' You must pass the drive to check as a command line parameter.
- ' For example:
- '
- ' FreeSpace.vbs C:
- '
- ' IMPORTANT: The drive letter must be in that format, e.g. C:\
- ' will fail. It must be drive letter followed by a colon only.
- '
- const MBFREESPACEREQUIRED = 10 ' !!! Change as appropriate - this is in MBytes
- const ONEMB = 1048576
-
- Set objArgs = WScript.Arguments
- If (objArgs.Count < 1) then
- WScript.Echo "No filename or dirname to copy was supplied."
- else
- Set objWMIService = GetObject("winmgmts:")
- For I = 0 To objArgs.Count - 1
- Set objLogicalDisk = objWMIService.Get("Win32_LogicalDisk.DeviceID='" & objArgs.Item(i) & "'")
- if objLogicalDisk.FreeSpace / ONEMB < MBFREESPACEREQUIRED then
- MsgBox ("There is less than " & MBFREESPACEREQUIRED & "MBytes of free disk space available on " & objArgs.Item(i))
- ' Wscript.Echo "There is less than " & MBFREESPACEREQUIRED & "MBytes of free disk space available on " & objArgs.Item(i)
- WScript.Quit(1)
- end if
- Next
- end if
- WScript.Quit(0)
-